package com.system.common.factory;

import com.system.common.enums.FactoryEnum;
import com.system.common.processor.CacheProcessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author: lslands
 * @version: 1.0
 * @create: 2024/5/19
 * @description:
 */
@Component
public class CacheFactory {
    private final Map<String, CacheProcessor> processorMap = new ConcurrentHashMap<>();

    @Autowired
    public CacheFactory(Map<String, CacheProcessor> beansOfType) {
        // 将所有实现了Processor接口的Bean注入到map中
        this.processorMap.putAll(beansOfType);
    }

    public CacheProcessor implementCacheProcessor(String type) {
        return processorMap.get(type);
    }

}
